package com.zhangck.bos2_0.Service.transit.Impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.zhangck.bos2_0.Service.take_delivery.wayBillIndexServices;
import com.zhangck.bos2_0.Service.transit.SignInfoService;
import com.zhangck.bos2_0.dao.Transit.SignInfoServiceRepository;
import com.zhangck.bos2_0.dao.Transit.TransitInfoRepository;
import com.zhangck.bos2_0.index.indexRepository;

import cn.itcast.bos.domain.transit.SignInfo;
import cn.itcast.bos.domain.transit.TransitInfo;

/** 
* @author 上午茶
* @version 创建时间：2018年6月20日 上午9:53:19 
* 类说明 
*/
@Service
@Transactional
public class SignInfoServiceImpl implements SignInfoService {

	@Autowired
	private SignInfoServiceRepository signInfoServiceRepository;
	
	@Autowired
	private TransitInfoRepository transitInfoRepository;
	
	@Autowired
	private indexRepository indexRepository;
	@Override
	public void save(String transitInfoId, SignInfo model) {
		signInfoServiceRepository.save(model);
		
		TransitInfo transitInfo = transitInfoRepository.findOne(Integer.parseInt(transitInfoId));
		
		if (model.getSignType().equals("正常")) {
			transitInfo.setStatus("正常签收");
			
			transitInfo.getWayBill().setSignStatus(3);
			
			indexRepository.save(transitInfo.getWayBill());	
			}else{
				transitInfo.setStatus("异常");
				
				transitInfo.getWayBill().setSignStatus(4);
			
				indexRepository.save(transitInfo.getWayBill());
			}
	}

}
